import java.util.Scanner;

public class test3 {
    //作业
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println("输入任意数字以外的字符退出程序");

        while (true) {
            getAvg();
        }
    }

    private static void getAvg(){
        System.out.println("请输入一个正整数（输入负数结束）:");
        int n = scan.nextInt();
//        try {
//            n = scan.nextInt();
//        }catch ()
        int sum = 0;
        int count = 0;
        while (n>=0){
            sum+=n;
            count++;
            System.out.println("请输入一个正整数（输入负数结束）:");
            n = scan.nextInt();
        }
        System.out.println("总和："+sum);
        System.out.println("平均值："+(double)(sum/count));
    }
}
